<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="twitter:site" content="@metroui">
    <meta name="twitter:creator" content="@pimenov_sergey">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="Metro 4 Components Library">
    <meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">

    <meta property="og:url" content="https://metroui.org.ua/v4/index.html">
    <meta property="og:title" content="Metro 4 Components Library">
    <meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="968">
    <meta property="og:image:height" content="504">

    <meta name="author" content="Sergey Pimenov">
    <meta name="description" content="The most popular HTML, CSS, and JS library in Metro style.">
    <meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">

    <link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon">
    <link rel="icon" href="../../favicon.ico" type="image/x-icon">

    <link href="../../metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
    <link href="../../css/site.css" rel="stylesheet">

    <title>Color schemes - Metro 4 :: Popular HTML, CSS and JS library</title>

    <style>
        .cell {
            color: white;
        }
    </style>

</head>
<body>
    <div class="container">
        <h1>Metro 4 Color generator</h1>
        <div class="bg-light p-4">
            <select data-role="select" id="scheme-name" data-prepend="Scheme: ">
                <option value="mono">monochromatic</option>
                <option value="analog">analogous</option>
                <option value="triadic">triadic</option>
                <option value="tetradic">tetradic</option>
                <option value="square">square</option>
                <option value="complementary">complementary</option>
                <option value="double-complementary">double-complementary</option>
                <option value="split-complementary">split-complementary</option>
            </select>

            <br />

            <div class="row">
                <div class="cell-md-4">
                    <input type="number" min="0" max="360" id="options-angle" value="30" data-role="input" data-prepend="Angle: ">
                </div>
                <div class="cell-md-4">
                    <select data-role="select" data-prepend="Algo: " id="options-algorithm">
                        <option value="1">Monochromatic 1</option>
                        <option value="2">Monochromatic 2</option>
                        <option value="3" selected>Monochromatic 3</option>
                        <option value="4">Monochromatic 4</option>
                    </select>
                </div>
                <div class="cell-md-4">
                    <input type="number" min="0" max="10" id="options-step" value="1" data-role="input" data-prepend="Step: ">
                </div>
            </div>
        </div>

        <div id="scheme-container"></div>

    </div>

    <script src="../../metro/js/metro.js"></script>
    <!-- ads-script -->

    <script>
        $(function(){
            'use strict';
            var cm = Metro.colors;
            var palette = cm.PALETTES.ALL;
            var container = $("#scheme-container");
            var select = $("#scheme-name");
            var colors = cm.palette(palette);
            var algorithm = $("#options-algorithm");
            var angle = $("#options-angle");
            var step = $("#options-step");

            select.on(Metro.events.change, function(){
                var scheme_name = this.value;
                var alg = algorithm.val() !== "" ? parseInt(algorithm.val()) : 1;
                var ang = angle.val() !== "" ? parseInt(angle.val()) : 1;
                var stp = step.val() !== "" ? parseFloat(step.val()) / 10 : .1;

                console.log("Angle: ", ang);
                console.log("Algorithm: ", alg);
                console.log("Step: ", stp);

                container.html("");

                $.each(colors, function(){
                    var color = String(this);

                    if (['white', 'black'].indexOf(color) !== -1) {
                        return ;
                    }

                    var color_hex = cm.color(color, palette);
                    var target = $("<div>").addClass("row flex-align-center m-0").appendTo(container);

                    var scheme_colors = cm.createScheme(color_hex, scheme_name, 'hex', {
                        angle: ang,
                        algorithm: alg,
                        step: stp,
                        distance: 5
                    });
                    $("<div>").addClass("p-4 cell text-center mr-4  " + (cm.isLight(color_hex) ? "fg-dark" : "fg-white")).html("<span class='reduce-3 text-ellipsis'>"+color+"</span>").attr("style", "width: 100px!important; background-color:"+ color_hex).appendTo(target);
                    $.each(scheme_colors, function(key, bg_color){
                        $("<div>").addClass("p-4 cell text-center " + (cm.isLight(bg_color) ? "fg-dark" : "fg-white")).html(bg_color).attr("style", "background-color:"+ bg_color).appendTo(target);
                    })
                });
            });

            algorithm.on("change", function(){
                select.trigger("change");
            })

            $("#options-angle, #options-step").on(Metro.events.inputchange, function(){
                select.trigger("change");
            });

            select.trigger("change");
        })
    </script>

</body>
</html>